
@echo off

rem 启动 node.js index.js，不等待其完成，并且隐藏窗口
start "" node index.js

rem 设置要监听的程序的路径和名称
set "program_command=C:\Program Files (x86)\Tencent\WeChat\WeChat.exe"

:loop

rem 等待程序退出
timeout /t 10 >nul
tasklist /fi "imagename eq WeChat.exe" 2>nul | find /i "WeChat.exe" >nul
if errorlevel 1 (
    echo WeChat.exe has terminated. Restarting  
    start "" "%program_command%" 
) else (
    echo WeChat.exe is running.
)
goto loop